<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Ldap
 * @subpackage Filter
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Abstract.php 10 2008-11-08 17:17:02Z Stefan.Gehrig.HN $
 */

/**
 * Zend_Ldap_Filter_Abstract provides a base implementation for filters.
 *
 * @category   Zend
 * @package    Zend_Ldap
 * @subpackage Filter
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class Zend_Ldap_Filter_Abstract 
{
    /**
     * Returns a string representation of the filter.
     *
     * @return string
     */
    abstract public function toString();
    
    /**
     * Returns a string representation of the filter.
     * @see toString()
     *
     * @return string
     */
    public function __toString()
    {
        return $this->toString();
    }
    
    /**
     * Negates the filter.
     *
     * @return Zend_Ldap_Filter_Abstract
     */
    public function negate()
    {
        /** 
         * Zend_Ldap_Filter_Not
         */
        require_once 'Zend/Ldap/Filter/Not.php';
        return new Zend_Ldap_Filter_Not($this);        
    }
    
    /** 
     * Creates an 'and' filter.
     *
     * @param  Zend_Ldap_Filter_Abstract $filter,...
     * @return Zend_Ldap_Filter_And
     */
    public function addAnd($filter)
    {
        /** 
         * Zend_Ldap_Filter_And
         */
        require_once 'Zend/Ldap/Filter/And.php';
        $fa=func_get_args();
        $args=array_merge(array($this), $fa);
        return new Zend_Ldap_Filter_And($args);
    }
    
    /**
     * Creates an 'or' filter.
     *
     * @param  Zend_Ldap_Filter_Abstract $filter,...
     * @return Zend_Ldap_Filter_Or
     */
    public function addOr($filter)
    {
        /** 
         * Zend_Ldap_Filter_Or
         */
        require_once 'Zend/Ldap/Filter/Or.php';
        $fa=func_get_args();
        $args=array_merge(array($this), $fa);
        return new Zend_Ldap_Filter_Or($args);
    }
}